package com.maya.screens;

import com.maya.R;
import java.util.List;


import com.maya.scoresUtility.Score;
import com.maya.scoresUtility.ScoresManager;
import com.maya.scoresUtility.ScoreItemAdapter;
import com.maya.scoresUtility.ScoresManagerFactory;
import com.maya.utilities.Utilities;

import android.app.ListActivity;

import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;


public class BestScoresScreen extends ListActivity implements OnClickListener
{
	private Button buttonMainMenu;
	
	private ScoresManager scoresManager;
	
	private TextView emptyView;
	private String gameGroup = "";
	
	Utilities util = new Utilities();
	PreferencesScreen pref = new PreferencesScreen();
	
	@Override
    public void onCreate(Bundle savedInstanceState) 
    {	
	    gameGroup = "Grup";
		
		super.onCreate(savedInstanceState);
        setContentView(R.layout.bestscores);
        
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        
        buttonMainMenu = (Button) findViewById(R.id.buttonMainMenu);
        buttonMainMenu.setOnClickListener(this);
          
        emptyView = (TextView)findViewById(R.id.empty);

        final ListView listView = getListView();
        listView.setItemsCanFocus(false);
        listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
        listView.setEmptyView(emptyView);

        scoresManager = ScoresManagerFactory.getScoresManager(getApplicationContext());
    }
		
	@Override
    protected void onResume() 
	{
        super.onResume();

        List<Score> scores = scoresManager.getScoresByGroup(gameGroup);
        setListAdapter(new ScoreItemAdapter(this, scores));
    }

	public void onClick(View v) 
	{
		if(v == buttonMainMenu) 
		{	
			startActivity(new Intent(BestScoresScreen.this, MainScreen.class));
		}
		
	}
}